const express = require('express')
const bodyParser = require('body-parser')
const path = require('path')
const homeRouter = require('./routes/home')
const newsRouter = require('./routes/news')
const app = express()
// 解析post参数
app.use(bodyParser.urlencoded({extended:false}))
app.use(bodyParser.json())
// 静态资源
app.use('/static',express.static(path.join(__dirname,'public')))
// 设置模板引擎

app.set('views',path.join(__dirname,"views"))
app.set('view engine','ejs')

app.use(homeRouter)
app.use(newsRouter)
/*
// 路由中间件
const router = express.Router();
// 相当于 小型 app(应用实例) 有get post use
router.get('/a',(req,res)=>{
    res.send('aaa')
})
app.use(router)
*/
app.listen(9527,()=>{console.log('start at port 9527')})